# coding: utf-8

from gensim import corpora, models
import pprint


corpus = [dic.doc2bow(text) for text in data_list]
tfidf = models.TfidfModel(corpus)
corpus_tfidf = tfidf[corpus]
# print(tfidf.__dict__)
# print(corpus_tfidf.__dict__)
# for item in corpus_tfidf:
#     print(item)

lsi = models.LsiModel(corpus_tfidf, num_topics=2, id2word=dic)
topic_result = [a for a in lsi[corpus_tfidf]]
# print(lsi.print_topics(num_topics=2, num_words=5))
for item in topic_result:
    print(topic_result)

lda = models.LdaModel(corpus_tfidf, num_topics=2, id2word=dic, alpha='auto', eta='auto',
                      minimum_probability=0.001)

doc_topic = [a for a in lda[corpus_tfidf]]
pprint.pprint(doc_topic)
print()
for topic_id in range(2):
    # pprint.pprint(lda.get_topic_terms(topicid=topic_id))
    pprint.pprint(lda.show_topic(topicid=topic_id))
